package test1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);
        Scanner sc = new Scanner(System.in);
        OutputStream os = socket.getOutputStream();
        while (true) {
            System.out.println("输入发出的消息:");
            String str = sc.nextLine();
            if("886".equals(str)) break;
            //readLine()是以\n为结束标识符的所以要加
            os.write((str + "\n").getBytes());
            //刷新缓冲区才能每发一句服务端打印一句
            os.flush();
        }
        socket.close();
    }
}
